import { ApiProperty, PickType } from '@nestjs/swagger';
import { IsInt, IsOptional, IsString, Length } from 'class-validator';
import { ArticleCategoryEntity } from './article-category.entity';

export class CreateArticleCategoryDto extends PickType(ArticleCategoryEntity, [
  'name',
  'description',
  'status',
] as const) {
  @ApiProperty({ description: '分类名称', default: '分类', required: true })
  @IsString({ message: '分类名称必须是字符串' })
  @Length(1, 50, { message: '分类名称长度必须在1到50之间' })
  name: string;

  @ApiProperty({ description: '分类描述', default: '分类描述' })
  @IsOptional()
  @IsString({ message: '分类描述必须是字符串' })
  @Length(1, 255, { message: '分类描述长度必须在1到255之间' })
  description: string;

	@ApiProperty({ description: '父级ID', default: null })
	@IsInt({ message: '父级ID必须是数字' })
	@IsOptional()
	parentId: number;

  @ApiProperty({ description: '租户ID', default: null, required: true })
  @IsInt({ message: '租户ID必须是数字' })
  @IsOptional()
  tenantId: number;
}
